package com.etc.serviceimpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.etc.dao.MediaMapper;
import com.etc.entity.Media;
import com.etc.entity.User;
import com.etc.service.MediaService;
import com.etc.tools.PageData;

@Service(value = "mediaServiceImpl")
public class MediaServiceImpl implements MediaService {

	@Resource
	private MediaMapper mm;

	@Override
	public boolean deleteByPrimaryKey(Integer mid) {

		return mm.deleteByPrimaryKey(mid) > 0;
	}

	@Override
	public boolean insert(Media media) {

		return mm.insert(media) > 0;
	}

	@Override
	public boolean insertSelective(Media media) {

		return mm.insertSelective(media) > 0;
	}

	@Override
	public Media selectByPrimaryKey(Integer mid) {
		// TODO Auto-generated method stub
		return mm.selectByPrimaryKey(mid);
	}

	@Override
	public boolean updateByPrimaryKeySelective(Media media) {
		// TODO Auto-generated method stub
		return mm.updateByPrimaryKeySelective(media) > 0;
	}

	@Override
	public boolean updateByPrimaryKey(Media media) {
		// TODO Auto-generated method stub
		return mm.updateByPrimaryKey(media) > 0;
	}

	@Override
	public List<Media> getAllMedia() {
		// TODO Auto-generated method stub
		return mm.selectAllMedia();
	}
	
	@Override
	public PageData<Media> getMediaByPage(int page, int pageSize, String content) {
		int start = (page - 1) * pageSize;
		List<Media> list = mm.getMediaByPage(start, pageSize, content);
		int count = mm.selectCount(content);
		PageData<Media> pd = new PageData<>(list, count, pageSize, page);
		return pd;
	}

}
